﻿using Abp.Quartz;
using DualControl.Web.Quartz;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace DualControl.Quartz
{
    public class JobManager: DualControlAppServiceBase, IJobManager
    {
        private readonly IQuartzScheduleJobManager _jobManager;
        public JobManager(IQuartzScheduleJobManager jobManager)
        {
            _jobManager = jobManager;
        }

        public void ScheduleGenerateCheckTask()
        {
            _jobManager.ScheduleAsync<GenerateTaskJob>(
               job =>
               {
                   job.WithIdentity("Cycle Check Tasks", "Quartz Scheduled Tasks")
                       .WithDescription("生成排查任务");
               },
               trigger =>
               {                  
                   trigger.StartNow()                  
                   .WithCronSchedule("0 1 1 ? * MON-FRI") //每天夜间1点1分生成排查任务0 1 1 * * ?
                   .Build();
               });

            _jobManager.Start();


        }
    }
}
